﻿#ifndef __UNI_POINTER_H__
#define __UNI_POINTER_H__

#if __cplusplus>=201103L
#include <memory>
#define SS_SHARED_PTR std::shared_ptr
#define SS_SHARED_ARRAY std::shared_ptr
#define SS_MAKE_SHARED std::make_shared
#else
#include "boost/smart_ptr.hpp"
#define SS_SHARED_PTR boost::shared_ptr
#define SS_SHARED_ARRAY boost::shared_array
#define SS_MAKE_SHARED boost::make_shared
#endif

namespace StarSeeker
{

	template<typename ARRAY_TYPE>
	inline SS_SHARED_ARRAY<ARRAY_TYPE> make_shared_array(unsigned int count)
	{
#if __cplusplus>=201103L
		return std::shared_ptr<ARRAY_TYPE>(new ARRAY_TYPE[count], std::default_delete<ARRAY_TYPE[]>());
#else
		return boost::shared_array<ARRAY_TYPE>(new ARRAY_TYPE[count]);
#endif
	}

	template<typename ARRAY_TYPE>
	inline SS_SHARED_ARRAY<ARRAY_TYPE> make_shared_array(ARRAY_TYPE* ptr)
	{
#if __cplusplus>=201103L
		return std::shared_ptr<ARRAY_TYPE>(ptr, std::default_delete<ARRAY_TYPE[]>());
#else
		return boost::shared_array<ARRAY_TYPE>(ptr);
#endif
	}

}
#endif
